package datatypes.r2.foundation.impl;

import javax.persistence.Entity;

import datatypes.r2.basic.CS;
import datatypes.r2.basic.impl.CodedSimpleValue;
import datatypes.r2.flavors.BN;
import datatypes.r2.flavors.impl.BooleanNonNull;
import datatypes.r2.foundation.ANY;
import datatypes.r2.foundation.BL;
import datatypes.r2.foundation.TYPE;

/**
 * 
 * An abstract type that defines the basic properties common to all data values
 * defined in this specification. Data Value is an abstract type, meaning that
 * no proper value can be just a data value without belonging to any concrete
 * type. Every concrete type is a specialization of this general abstract
 * DataValue type.
 * 
 * @author Obama
 * 
 */
public class DataValue implements ANY {
	
	private static final long serialVersionUID = 1L;
	/**
	 * The data type of the value.
	 */
	private DataType dataType;
	/**
	 * An indicator of a data value's exceptional status, sometimes also
	 * denoting the manner and rationale for that status.
	 */
	private CodedSimpleValue nullFlavor;
	/**
	 * A predicate indicating that that a property has a value, i.e. is a
	 * non-null ("non-exceptional") value of the data type.
	 */
	private boolean nonNull;
	/**
	 * A predicate indicating that that a value is an exceptional value, or a
	 * null-value. A null value means that the information does not exist, is
	 * not available, or cannot be expressed in the data type's normal value
	 * set.
	 */
	private boolean isNull;
	/**
	 * A predicate indicating that this exceptional value is of nullFlavor
	 * not-applicable (NA), i.e., that a proper value is not meaningful in the
	 * given context.
	 */
	private Boolean notApplicable;
	/**
	 * A predicate indicating that this exceptional value is of nullFlavor
	 * unknown (UNK).
	 */
	private Boolean unknown;
	/**
	 * A predicate indicating that this exceptional value is of nullFlavor other
	 * (OTH), i.e., that the required value domain does not contain the
	 * appropriate value.
	 */
	private Boolean other;

	/**
	 * A reflexive, symmetric, and transitive relation between any two data
	 * values indicating that the two values are the same.
	 * 
	 * @param x
	 * @return
	 */
	public Boolean equal(DataValue x) {
		return new Boolean(this.equals(x));
	}

	/**
	 * Identity comparison is a reflexive, symmetric, and transitive relation
	 * between any two data values. Any values can be identical, whether or not
	 * they are null or contain property with null values. The identity
	 * comparison always returns true or false. The result is never null.
	 * 
	 * @param x
	 * @return
	 */
	protected boolean identical(DataValue x) {
		return false;
		// TODO
	}

	@Override
	public TYPE dataType() {
	
		return dataType;
	}

	@Override
	public CS nullFlavor() {
		return null;
	}

	@Override
	public BN nonNull() {
		return new BooleanNonNull(nonNull);
	}

	@Override
	public BN isNull() {
		return null;
	}

	@Override
	public BL notApplicable() {
		return null;
	}

	@Override
	public BL unknown() {
		return null;
	}

	@Override
	public BL other() {
		return null;
	}

	@Override
	public BL equal(ANY x) {
		return null;
	}

	@Override
	public BN identical(ANY x) {
		return null;
	}

	

}
